package sony.sonyorderservice;

import com.sony.types.Item;
import com.sony.types.Quote;
import javax.ejb.Stateless;
import javax.jws.WebService;

@WebService(name = "SonyOrderService", serviceName = "SonyOrderService")
@Stateless()
public class SonyOrderServiceImp {

    public boolean orderQuoute(String orderId) {
        return true;
    }

    public Quote processQuote(String orderId, Item[] items) {
        Long totalPrice = new Long(0);


        for (int i = 0; i < items.length; i++) {
            Item localItem = items[i];
            totalPrice += localItem.getQuantity() * (((Long.valueOf(orderId) % 2) == 0) ? 250 : 1);
        }
        Quote priceQuote = new Quote();
        priceQuote.setSupplierPrice(totalPrice.toString());
        
        System.out.println("Cotizacion Sony --- Orden " + orderId + " Valor  " + totalPrice);
        return priceQuote;

    }
}
